package chapter3;
import java.util.Scanner;
/****************************************************************
 * Author：icynlau
 * Description:  货币兑换
 * Date:2021/4/2
 * ***************************************************************
 */
public class exc3_31 {
	public static void main(String[] args) {
		
		Scanner input=new Scanner(System.in);
		System.out.print("Enter the exchange rate from dollars to RMB: ");
		final double RMB_PER_DOLLAR=input.nextDouble();
		System.out.print("Enter 0 to convert dollars to RMB and1 vice versa: ");
		int type=input.nextInt();
		String moneyType="";
		if(type==0) {
			moneyType="dollar";
		}else {
			moneyType="RMB";
		}
		System.out.print("Enter the "+moneyType+" amount:");
		double amount=input.nextDouble();
		if(type==0) {
			System.out.format("$ %.2f is %.2f yuan",amount,amount*RMB_PER_DOLLAR);
		}else {
			System.out.format(" %.2f yuan is $%.2f ",amount,amount/RMB_PER_DOLLAR);
		}
		
		
	}

}
